package org.kosta.android.samples.part1;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SampleCodeActivity extends Activity {
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        /** layout start*/
        LinearLayout ll = new LinearLayout(this); //뷰그룹을 생성한다.
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setGravity(Gravity.CENTER); //센터정렬

        TextView titleTextView = new TextView(this); //텍스트뷰를 생성한다.
        titleTextView.setText("무작정 따라하기");
        titleTextView.setTextSize(20);
        
        Button mBtn1 = new Button(this); //첫번째 버튼을 만든다.
        mBtn1.setText("버튼1");
        
        Button mBtn2 = new Button(this); //두번째 버튼을 만든다.
        mBtn2.setText("종료");
        mBtn2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});

        int lHeight = LinearLayout.LayoutParams.WRAP_CONTENT;
        int lWidth = LinearLayout.LayoutParams.WRAP_CONTENT;

        ll.addView(titleTextView, new LinearLayout.LayoutParams(lWidth, lHeight));
        ll.addView(mBtn1, new LinearLayout.LayoutParams(200, lHeight));
        ll.addView(mBtn2, new LinearLayout.LayoutParams(200, lHeight));
        
        setContentView(ll);
        /** layout end */  
    }
}